import time

from selenium.webdriver.common.by import By

from base.page_base import BasePage
from tools import DriverTools


class LoginPage(BasePage):
    def __init__(self, driver):
        super().__init__(driver)
        self.phone = By.XPATH, '//*[@id="keywords"]'
        self.password = By.XPATH, '//*[@id="password"]'
        self.login1 = By.XPATH, '//*[@id="login-btn"]'
        self.opened = By.XPATH, '//*[@id="mlayout"]/div[2]/div[3]/div/div[1]/div/a'
        self.name = By.XPATH, '//*[@id="safeName"]/div[2]/input'
        self.number = By.XPATH, '//*[@id="safeName"]/div[3]/input'
        self.result= By.XPATH, '//*[@id="mlayout"]/div[1]/div[1]/div/div[2]/li[1]/span/a'
        #用户不存在
        self.user_not= By.XPATH, '//*[@id="err"]/span'

    # def login(self,phone,pwd):
        # self.fd_element(self.phone).send_keys(phone)
        # self.fd_element(self.password).send_keys(pwd)
        # self.fd_element(self.login1).click()
    def login(self, phone, pwd):
        self.base_input(self.phone, phone)
        self.base_input(self.password, pwd)
        self.base_click(self.login1)

    def get_login_result(self):
        time.sleep(2)
        result= self.get_handle(self.result).text
        return result
    def get_uesr_not(self):
        result= self.fd_element(self.user_not).text
        return result
